package com.tsinghuabigdata.edu.ddmath.activity;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;


import com.tsinghuabigdata.edu.ddmath.R;
import com.tsinghuabigdata.edu.ddmath.adapter.SelectBaseAdapter;
import com.tsinghuabigdata.edu.ddmath.bean.DayQuestions;
import com.tsinghuabigdata.edu.ddmath.bean.Question;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;


public class SelectQuestionsActivity extends RoboActivity implements View.OnClickListener {

    private static final String TAG = "sky";

    private Context      mContext;
    private LinearLayout mLlBack;
    private ListView     mLvSelectQuestions;
    private Button       mBtnFinishSelect;

    private void assignViews() {

    }


    private SelectBaseAdapter mAdatper;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_select_questions);
        mContext = this;
        initViews();
        initData();
    }


    private void initViews() {
        mLlBack = (LinearLayout) findViewById(R.id.ll_back);
        mLvSelectQuestions = (ListView) findViewById(R.id.lv_select_questions);
        mBtnFinishSelect = (Button) findViewById(R.id.btn_finish_select);

        mLlBack.setOnClickListener(this);
        mLvSelectQuestions.setOnClickListener(this);
    }

    private void initData() {
        List<DayQuestions> dayQuestionsList = new ArrayList<DayQuestions>();
        for (int i = 0; i < 6; i++) {
            DayQuestions dayQuestions = new DayQuestions();
            dayQuestions.setDay("2017年3月" + (7 - i) + "日");
            List<Question> list = new ArrayList<Question>();
            Random random = new Random();
            for (int j = 0; j < random.nextInt(20); j++) {
                Question question = new Question();
                list.add(question);
            }
            dayQuestions.setList(list);
            dayQuestionsList.add(dayQuestions);
        }
        //        SelectQuestionsAdatper adatper = new SelectQuestionsAdatper(this, dayQuestionsList);
        mAdatper = new SelectBaseAdapter(this, dayQuestionsList);
        mLvSelectQuestions.setAdapter(mAdatper);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.ll_back:
                mAdatper.cancel();
                break;
            case R.id.btn_finish_select:

                break;
        }
    }


}
